package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SysDepartmentControllerApi;
import com.nineclock.system.service.SysDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@RestController
@RequestMapping("/department")
public class SysDepartmentController  implements SysDepartmentControllerApi{

    @Autowired
    SysDepartmentService departmentService;

    /**
     * 根据员工id查询 ， 该员工所在部门id， 以及上级部门id（依次获取）
     * @param companyUserId
     * @return
     */
    @GetMapping("/allDepId/{companyUserId}")
    public Result<List<Long>> queryDepartmentsByUserId(@PathVariable("companyUserId") Long companyUserId) {
        List<Long> ids = departmentService.queryDepartmentsByUserId(companyUserId);
        return Result.success(ids);
    }
}
